﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Drawing;
using System.Windows.Forms;
using Styx;
using Styx.Combat.CombatRoutine;
using Styx.Helpers;
using Styx.Logic;
using Styx.Logic.Combat;
using Styx.Logic.Pathing;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.Logic.POI;

namespace HarmoniousVigor
{
    public partial class Mage
    {
        public bool frostCombat()
        {
            if (Battlegrounds.IsInsideBattleground)
            {
                if (frostPVPCombat())
                    return true;
            }
            else if (characterPlayer.IsInInstance)
            {
                if (frostDungeonCombat())
                    return true;
            }
            else
            {
                if (frostQuestingCombat())
                    return true;
            }

            return false;
        }
        public bool frostHeal()
        {
            if (Battlegrounds.IsInsideBattleground)
            {
                if (frostPVPHeal())
                    return true;
            }
            else if (characterPlayer.IsInInstance)
            {
                if (frostDungeonHeal())
                    return true;
            }
            else
            {
                if (frostQuestingHeal())
                    return true;
            }

            return false;
        }
        public bool frostBuff()
        {
            if (Battlegrounds.IsInsideBattleground)
            {
                if (frostPVPBuff())
                    return true;
            }
            else if (characterPlayer.IsInInstance)
            {
                if (frostDungeonBuff())
                    return true;
            }
            else
            {
                if (frostQuestingBuff())
                    return true;
            }

            return false;
        }
        public bool frostPullSpell()
        {
            if (Battlegrounds.IsInsideBattleground)
            {
                if (frostPVPPullSpell())
                    return true;
            }
            else if (characterPlayer.IsInInstance)
            {
                if (frostDungeonPullSpell())
                    return true;
            }
            else
            {
                if (frostQuestingPullSpell())
                    return true;
            }

            return false;
        }


        public bool frostRegularBehavior()
        {
            if (characterPlayer.CurrentTarget == null || characterPlayer.Mounted)
                return true;
            rangedMovement();
            faceTarget();
            AutoAttack();
            return false;
        }

        public bool frostCombatBehavior()
        {
            if (characterPlayer.HasAura("Brain Freeze") && characterPlayer.CurrentTarget.Distance2D < 40)
            {
                if (Utils.CastTarget("Fireball", characterPlayer.CurrentTarget))
                    return true;
            }

            if (characterPlayer.HasAura("Fingers of Frost"))
            {
                if (characterPlayer.CurrentTarget.Distance2D < 35)
                {
                    if (Utils.CastTarget("Deep Freeze", characterPlayer.CurrentTarget))
                        return true;

                    if (Utils.CastTarget("Ice Lance", characterPlayer.CurrentTarget))
                        return true;
                }
            }




            if (characterPlayer.CurrentTarget.Distance2D < 35)
            {
                if (SpellManager.CanCast("Frostbolt"))
                {
                    Navigator.PlayerMover.MoveStop();
                    StyxWoW.SleepForLagDuration();

                    if (Utils.CastTarget("Frostbolt", characterPlayer.CurrentTarget))
                        return true;
                }

                if(Utils.CastTarget("Ice Lance", characterPlayer.CurrentTarget))
                    return true;
            }

            return false;

        }
    }
}
